#!/bin/bash
set -e
set -o pipefail

# Run Redis docker container
docker start buildfarm-redis || docker run -d --rm --name buildfarm-redis -p 6379:6379 redis:5.0.9
redis-cli config set stop-writes-on-bgsave-error no

# Determine which configuration file to use - default or user provided
if [[ -z "$1" ]]
then
  config=$PWD/examples/config.minimal.yml
else
  config=$1
fi

# Run Server
bazelisk run //src/main/java/build/buildfarm:buildfarm-shard-worker -- --jvm_flag=-Dlogging.config=file:$PWD/examples/logging.properties $config